package cn.jiyun.controller;

import cn.jiyun.pojo.SpecialCoefficient;
import cn.jiyun.pojo.SpecialCoefficientTwo;
import cn.jiyun.service.SpecialCoefficientService;
import cn.jiyun.vo.ResultCommon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/spe")
@CrossOrigin
public class SpecialCoefficientController {
    @Autowired
    private SpecialCoefficientService specialCoefficientService;
    @GetMapping("/findAll")
    public ResultCommon findAll(){
        List<SpecialCoefficient> specialCoefficientList = specialCoefficientService.findAll();
        return ResultCommon.suceessData(specialCoefficientList);
    }
    @PostMapping("/add")
    public ResultCommon add(@RequestBody SpecialCoefficientTwo specialCoefficientTwo){
        specialCoefficientService.add(specialCoefficientTwo);
        return ResultCommon.suceess();
    }
    @GetMapping("/deletebyid")
    public ResultCommon deletebyid( @RequestParam("id") Integer id){
        specialCoefficientService.deletebyid(id);
        return ResultCommon.suceess();
    }
    @PostMapping("/updatebyid")
    public ResultCommon updatebyid(@RequestBody SpecialCoefficient specialCoefficient){
        specialCoefficientService.updatebyid(specialCoefficient);
        return ResultCommon.suceess();
    }
    @GetMapping("/findAllTwo")
    public ResultCommon findAllTwo(){
        List<SpecialCoefficientTwo> specialCoefficientList = specialCoefficientService.findAllTwo();
        return ResultCommon.suceessData(specialCoefficientList);
    }
}
